import instance from '../request'
import axios from 'axios'

/*
    id
    title
    isTop
    article
    topImg
    contentId
    categoryArr
    content
*/

export const createBlog = (data) => {
    return instance({
        url: '/abstract/create',
        data,
        method: 'POST'
    })
}

export const getBlog = (id) => {
    return instance({
        url: '/abstract/queryAbstract',
        method: 'GET',
        params: {
            id
        }
    })
}

const changeAbstract = (data) => {
    return instance({
        url: '/abstract/changeAbstract',
        method: 'PUT',
        data: {
            id: data.id,
            title: data.title,
            article: data.article,
            category_arr: data.category_arr,
            top_img: data.top_img,
        }
    })
}

const changeContent = (data) => {
    return instance({
        url: '/abstract/changeContent',
        method: 'PUT',
        data
    })
}


export const changeBlog = (data1, data2) => {
    return axios.all([changeAbstract(data1), changeContent(data2)])
}
